﻿using System.Web.Mvc;
using MinistryManager.DataAccess.Services;
using MinistryManager.Util.Authentication;
using MinistryManager.Util.Helpers;

namespace MinistryManager.Controllers
{
    public class LoginController : Controller
    {
        private readonly LoginHelper _helper;

        public LoginController()
        {
            _helper = new LoginHelper(new SessionFormsAuthentication(), new VolunteerService());
        }

        public LoginController(LoginHelper helper)
        {
            _helper = helper;
        }

        public ActionResult Login()
        {
            return View("Login");
        }

        public ActionResult LoginPost(string username, string password)
        {
            if (_helper.LoginUser(username, password))
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
                return View("Login");
            }
        }
    }
}
